
 
 *********************************************************
 * figure 5
 ******************************  ******************************

clear
use "data/both.dta", clear


drop if roll2==.

local np1 = _N + 36
 set obs `np1'
 replace treat=1 if treat==.
 sort treat
local np1 = _N + 36
 set obs `np1'
 replace treat=2 if treat==.
 sort treat

 gen temp=_n-1
 replace temp=temp[_n-6] if _n>6
replace roll1=temp if roll1==.
 
 replace temp=0
 replace temp=temp[_n-6]+1 if _n>6
replace temp=temp[_n-36] if treat==2
replace roll2=temp if roll2==.

egen temp_r1=rowmax(roll1 roll2)
egen temp_r2=rowmin(roll1 roll2) 
replace roll1=temp_r1 if treat==2
replace roll2=temp_r2 if treat==2

label define  temp_1 1 "Luck" 2 "Justified Dishonesty" 11 "Sample A, N=104" 12 "Sample B, N=89" 13 "Sample C, N=80" 14  "Sample D, N=87" 21 "Treatment E, N=127" 22"Treatment F, N=104" , replace
label values treat treatment temp_1


replace treat=treat+20 if treat>3 & treat<20 // to sort out the order

label define  temp_1 1 "Luck" 2 "Justified Dishonesty" 31 "Sample A, N=104" 32 "Sample B, N=89" 33 "Sample C, N=80" 34  "Sample D, N=87" 21 "Treatment 2S, N=127" 22 "Treatment 1S, N=104" , replace
label values treat treatment temp_1

gen one=1
bysort treat roll1 roll2: egen N_treat_cell=count(one)
bysort treat: egen N_treat=count(one)
gen N_cell_by_treat=100*N_treat_cell/N_treat
 heatplot  N_cell_by_treat i.roll2 i.roll1 , by(treat, scale(1.1) compact rows(2) legend(off) note("") )  statistic(mean ) values(label()  format(%9.1f) ) cut(1 2(2)14) col(sfso,  reverse intensity(.55) )  xtitle("First Report") ytitle("Second Report") fillin() 
 
 
 graph export "output/figure5.pdf", as(pdf) name("Graph") replace

  